home *** CD-ROM | disk | FTP | other *** search
/ Libris Britannia 4 / science library(b).zip / science library(b) / DJGPP / LGP250S1.ZIP / src / libgplus.5 / libgplus / genclass / gentest.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  1991-12-21  |  4KB  |  175 lines

  1. #!/bin/sh
  2.  
  3. #   Copyright (C) 1989 Free Software Foundation, Inc.
  4. #   
  5. #   genclass test program by Wendell C. Baker 
  6.  
  7. #This file is part of GNU libg++.
  8.  
  9. #GNU libg++ is free software; you can redistribute it and/or modify
  10. #it under the terms of the GNU General Public License as published by
  11. #the Free Software Foundation; either version 1, or (at your option)
  12. #any later version.
  13.  
  14. #GNU libg++ is distributed in the hope that it will be useful,
  15. #but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  17. #GNU General Public License for more details.
  18.  
  19. #You should have received a copy of the GNU General Public License
  20. #along with GNU libg++; see the file COPYING.  If not, write to
  21. #the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
  22.  
  23. #
  24. # test.sh
  25. #
  26. name=gentest.sh
  27. usage="$name" ;
  28. genclass=
  29.  
  30. case "$1" in
  31. -usage)
  32.     #
  33.     # -usage
  34.     #
  35.     echo "usage: $usage" 1>&2 ;
  36.     exit 0;
  37.     ;;
  38. -version)
  39.     #
  40.     # -version
  41.     #
  42.     version="`expr '$Revision: 1.3 $' : '.*Revision: \(.*\) .*'`" ;
  43.     echo "$name: version $version" ;
  44.     exit 0;
  45.     ;;
  46. -requires)
  47.     #
  48.     # -requires
  49.     #
  50.     echo genclass ;
  51.     exit 0;
  52.     ;;
  53. -genclass)
  54.     #
  55.     shift; genclass=$1
  56.     ;;
  57. esac ;
  58.  
  59. # pull it in from the environment
  60. [ "$TRACE" = "" ] || set -xv 
  61.  
  62. if [ "${genclass}" = "" ] 
  63. then 
  64.     genclass="./genclass"
  65. fi
  66.  
  67. for arg in -usage -version -requires -catalog -list ; do
  68.     echo "---------- genclass $arg ----------"
  69.     ${genclass} $arg
  70.     echo "-----------"
  71. done ;
  72.  
  73. arg="-catalog PQ Set"
  74. echo "---------- genclass $arg ----------"
  75. ${genclass} $arg
  76. echo "-----------"
  77.  
  78. arg="-list Map Stack"
  79. echo "---------- genclass $arg ----------"
  80. ${genclass} $arg
  81. echo "-----------"
  82.  
  83. std1=int ;
  84. std2=char ;
  85.  
  86. #
  87. # Do all of them with the single-type syntax
  88. # The Map-based classes are expected to fail (good)
  89. #
  90. for proto in `${genclass} -list` ; do
  91.     file_h=$std1.$proto.h
  92.     file_cc=$std1.$proto.cc
  93.     files="$file_h $file_cc" ;
  94.     echo "Generating: genclass $std1 ref $proto"
  95.     ${genclass} $std1 ref $proto
  96.     if [ $? != 0 ] ; then
  97.     echo "Generation for $std1-$proto failed"
  98.     else
  99.         echo "Checking for badsub"
  100.     egrep '<[TC]&?>' $files
  101.     echo "removing $files"
  102.     rm $files
  103.     fi ;
  104.     echo ""
  105.  
  106.     nonstd1=fig
  107.     file_h=$nonstd1$proto.h
  108.     file_cc=$nonstd1$proto.cc
  109.     files="$file_h $file_cc" ;
  110.     echo "genclass $std1 ref $proto $nonstd1"
  111.     ${genclass} $std1 ref $proto $nonstd1
  112.     if [ $? != 0 ] ; then
  113.     echo "Generation for $std1-$proto failed"
  114.     else
  115.     echo "Checking for badsub"
  116.     egrep '<[TC]?>' $files
  117.     echo "removing $files"
  118.     rm $files
  119.     fi ;
  120.     echo ""
  121.  
  122. done ;
  123.  
  124. #
  125. # Do them all again with the -2 syntax
  126. # None are expected to fail because there is no
  127. # way to tell something that requires the single-type syntax
  128. #
  129. for proto in `${genclass} -list` ; do
  130.     file1_h=$std1.$proto.h
  131.     file1_cc=$std1.$proto.cc
  132.     files1="$file1_h $file1_cc";
  133.     file2_h=$std1.$std2.$proto.h
  134.     file2_cc=$std1.$std2.$proto.cc
  135.     files2="$file2_h $file2_cc" ;
  136.     files="$file1_h $file1_cc $file2_h $file2_cc" ;
  137.     echo "Generating: genclass -2 $std1 ref $std2 val $proto"
  138.     ${genclass} -2 $std1 ref $std2 val $proto
  139.     if [ $? != 0 ] ; then
  140.     echo "Generation for $std1-$std2-$proto failed"
  141.     else
  142.     echo "Checking for badsub"
  143.     if [ -f $file1_h ] ; then
  144.         # then $file1_cc is expected to exist
  145.         egrep '<[TC]&?>' $files1
  146.         echo "removing $files1"
  147.         rm $files1
  148.     else 
  149.         # then [ -f $file2_h ]
  150.         # and $file2_cc is expected to exist
  151.         egrep '<[TC]&?>' $files2
  152.         echo "removing $files2"
  153.         rm $files2
  154.         fi ;
  155.     fi ;
  156.     echo ""
  157.  
  158.     nonstd=fig
  159.     file_h=$nonstd$proto.h
  160.     file_cc=$nonstd$proto.cc
  161.     files="$file_h $file_cc" ;
  162.     echo "Generating: genclass -2 $std1 ref $std2 val $proto $nonstd"
  163.     ${genclass} -2 $std1 ref $std2 val $proto $nonstd
  164.     if [ $? != 0 ] ; then
  165.     echo "Generation for $std1-$std2-$proto failed"
  166.     else
  167.         echo "Checking for badsub"
  168.     egrep '<[TC]&?>' $files
  169.     echo "removing $files"
  170.     rm $files
  171.     fi ;
  172.     echo ""
  173.  
  174. done ;
  175.